import javax.swing.tree.TreeNode;

public class Test {

    //平衡二叉树
    /**
    * 时间复杂度：O(N^2)*/

/*     public boolean isBalanced(TreeNode root) {
        if(root == null){
            return true;
        }
        int left = getHight(root.left);
        int right = getHight(root.right);
        if(Math.abs(left - right) > 1)
            return false;
        return isBalanced(root.left) && isBalanced(root.right);
    }

    public int getHight(TreeNode root){
        if(root == null){
            return 0;
        }

        int leftTree = getHight(root.left);
        int rightTree = getHight(root.right);

        return Math.max(leftTree,rightTree) + 1;
    } */

    /**
     * 时间复杂度:O(N)*/

   /*  public boolean isBalanced(TreeNode root) {
        if(root == null){
            return true;
        }

        return getHight(root) != -1;
    }

    public int getHight(TreeNode root){
        if(root == null){
            return 0;
        }

        int leftTree = getHight(root.left);
        if(leftTree < 0){
            return -1;
        }
        int rightTree = getHight(root.right);

        if(rightTree >= 0 && Math.abs(leftTree - rightTree) <= 1){
            return Math.max(leftTree,rightTree) + 1;
        }else {
            return -1;
        }
    } */

    //二叉搜索树与双向链表
   /*  public TreeNode Convert(TreeNode pRootOfTree) {
        if(pRootOfTree == null){
            return null;
        }
        ConvertChild(pRootOfTree);
        TreeNode head = pRootOfTree;
        while(head.left != null){
            head = head.left;
        }
        return head;
    }

    TreeNode prev = null;
    public void ConvertChild(TreeNode root) {
        if(root == null){
            return;
        }

        ConvertChild(root.left);

        root.left = prev;
        if(prev != null){
            prev.right = root;
        }
        prev = root;

        ConvertChild(root.right);
    } */



}


